﻿namespace Regent.Boo.NUnit
import System
import NUnit.Framework

[TestFixture]
class Component:

	[Test]
	public def Interface():
		c = Regent.Component()
		c.Init()
		c.Acquire()
		c.Restore()
		c.Update()
		c.Release()
		c.SetUpdateEnabled(true)
		c.SetAcquireEnabled(true)
		c.SetRestoreEnabled(true)
		c.SetReleaseEnabled(true)
	
	[Test]
	public def Usage():
		c = Regent.Component()

		c.Acquire()
		c.Restore()
		c.Update()
		c.Release()
		
		c.Init()
		c.Update()
		c.Release()

		c.SetAcquireEnabled(true)
		assert c.IsAcquireEnabled()
		c.SetAcquireEnabled(false)
		assert not c.IsAcquireEnabled()

		c.SetRestoreEnabled(true)
		assert c.IsRestoreEnabled()
		c.SetRestoreEnabled(false)
		assert not c.IsRestoreEnabled()

		c.SetUpdateEnabled(true)
		assert c.IsUpdateEnabled()
		c.SetUpdateEnabled(false)
		assert not c.IsUpdateEnabled()

		c.SetReleaseEnabled(true)
		assert c.IsReleaseEnabled()
		c.SetReleaseEnabled(false)
		assert not c.IsReleaseEnabled()

	[Test]
	public def State():
		c = Regent.Component()

		assert c.IsAcquireEnabled()
		assert c.IsRestoreEnabled()
		assert c.IsUpdateEnabled()
		assert not c.IsReleaseEnabled()

		c.Update()
		assert c.IsAcquireEnabled()
		assert c.IsRestoreEnabled()
		assert c.IsUpdateEnabled()
		assert not c.IsReleaseEnabled()

		c.Restore()
		assert c.IsAcquireEnabled()
		assert c.IsRestoreEnabled()
		assert c.IsUpdateEnabled()
		assert not c.IsReleaseEnabled()

		c.Release()
		assert c.IsAcquireEnabled()
		assert c.IsRestoreEnabled()
		assert c.IsUpdateEnabled()
		assert not c.IsReleaseEnabled()

		c.Acquire()
		assert not c.IsAcquireEnabled()
		assert c.IsRestoreEnabled()
		assert c.IsUpdateEnabled()
		assert c.IsReleaseEnabled()

		c.Restore()
		assert not c.IsAcquireEnabled()
		assert c.IsRestoreEnabled()
		assert c.IsUpdateEnabled()
		assert c.IsReleaseEnabled()

		c.Update()
		assert not c.IsAcquireEnabled()
		assert c.IsRestoreEnabled()
		assert c.IsUpdateEnabled()
		assert c.IsReleaseEnabled()

		c.Release()
		assert c.IsAcquireEnabled()
		assert not c.IsRestoreEnabled()
		assert not c.IsUpdateEnabled()
		assert not c.IsReleaseEnabled()

		c.Restore()
		assert c.IsAcquireEnabled()
		assert not c.IsRestoreEnabled()
		assert not c.IsUpdateEnabled()
		assert not c.IsReleaseEnabled()

		c.Update()
		assert c.IsAcquireEnabled()
		assert not c.IsRestoreEnabled()
		assert not c.IsUpdateEnabled()
		assert not c.IsReleaseEnabled()

		c.Release()
		assert c.IsAcquireEnabled()
		assert not c.IsRestoreEnabled()
		assert not c.IsUpdateEnabled()
		assert not c.IsReleaseEnabled()

		c.Acquire()
		assert not c.IsAcquireEnabled()
		assert c.IsRestoreEnabled()
		assert c.IsUpdateEnabled()
		assert c.IsReleaseEnabled()

	[Test]
	public def ProblematicStates():
		c = Regent.Component()

		assert not c.IsReleaseEnabled()
		c.Acquire()
		assert c.IsReleaseEnabled()
		c.Release()
		assert not c.IsReleaseEnabled()
		c.Acquire()
		assert c.IsReleaseEnabled()
		c.Release()
		assert not c.IsReleaseEnabled()

